﻿<UserControl x:Class="RZD_maps.Modules.Ribbon.Views.RibbonView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ribbon="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
             xmlns:data="clr-namespace:RZD_maps.Modules.Ribbon.Model"
             xmlns:local="clr-namespace:RZD_maps.Modules.Ribbon"
             Loaded="UserControl_Loaded"
             Unloaded="UserControl_Unloaded">
    <Grid>
        <Grid.Resources>
            <!-- RibbonControl -->
            <Style x:Key="RibbonControlStyle">
                <Setter Property="ribbon:RibbonControlService.Label" Value="{Binding Label}" />
                <Setter Property="ribbon:RibbonControlService.LargeImageSource" Value="{Binding LargeImage}" />
                <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{Binding SmallImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipTitle" Value="{Binding ToolTipTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipDescription" Value="{Binding ToolTipDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{Binding ToolTipImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterTitle" Value="{Binding ToolTipFooterTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterDescription" Value="{Binding ToolTipFooterDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{Binding ToolTipFooterImage}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding LargeImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.LargeImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SmallImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipFooterImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <Trigger Property="ribbon:RibbonControlService.IsInQuickAccessToolBar" Value="False">
                        <Setter Property="KeyTipService.KeyTip" Value="{Binding KeyTip}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonGroup -->
            <Style TargetType="{x:Type ribbon:RibbonGroup}"  BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="QuickAccessToolBarId" Value="{Binding Label}" />
                <Setter Property="Header" Value="{Binding Label}" />
            </Style>

            <!-- RibbonButton -->
            <Style TargetType="{x:Type ribbon:RibbonButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
            </Style>

            <!-- RibbonToggleButton -->
            <Style TargetType="{x:Type ribbon:RibbonToggleButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
            </Style>

            <!-- RibbonRadioButton -->
            <Style TargetType="{x:Type ribbon:RibbonRadioButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
            </Style>

            <!-- RibbonCheckBox -->
            <Style TargetType="{x:Type ribbon:RibbonCheckBox}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
            </Style>

            <!-- RibbonTextBox -->
            <Style TargetType="{x:Type ribbon:RibbonTextBox}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="Text" Value="{Binding Text}" />
            </Style>

            <!-- RibbonMenuButton -->
            <Style TargetType="{x:Type ribbon:RibbonMenuButton}" BasedOn="{StaticResource RibbonControlStyle}">
                <Setter Property="QuickAccessToolBarId" Value="{Binding Command}" />
                <Setter Property="CanUserResizeVertically" Value="{Binding IsVerticallyResizable}" />
                <Setter Property="CanUserResizeHorizontally" Value="{Binding IsHorizontallyResizable}" />
            </Style>

            <!-- RibbonSplitButton -->
            <Style TargetType="{x:Type ribbon:RibbonSplitButton}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuButton}}">
                <Setter Property="IsCheckable" Value="{Binding IsCheckable}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="HeaderQuickAccessToolBarId" Value="{Binding Label}" />
                <Setter Property="DropDownToolTipTitle" Value="{Binding DropDownButtonData.ToolTipTitle}" />
                <Setter Property="DropDownToolTipDescription" Value="{Binding DropDownButtonData.ToolTipDescription}" />
                <Setter Property="DropDownToolTipImageSource" Value="{Binding DropDownButtonData.ToolTipImage}" />
                <Setter Property="DropDownToolTipFooterTitle" Value="{Binding DropDownButtonData.ToolTipFooterTitle}" />
                <Setter Property="DropDownToolTipFooterDescription" Value="{Binding DropDownButtonData.ToolTipFooterDescription}" />
                <Setter Property="DropDownToolTipFooterImageSource" Value="{Binding DropDownButtonData.ToolTipFooterImage}" />
            </Style>

            <!-- RibbonComboBox -->
            <Style TargetType="{x:Type ribbon:RibbonComboBox}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuButton}}">
                <Setter Property="IsEditable" Value="True" />
                <Setter Property="CanUserResizeVertically" Value="True" />
            </Style>

            <!-- RibbonGallery FilterItemContainerStyle -->
            <Style TargetType="{x:Type ribbon:RibbonMenuItem}" x:Key="FilterMenuItemStyle">
                <Setter Property="Header" Value="{Binding Label}"/>
            </Style>

            <!-- RibbonGallery -->
            <Style TargetType="{x:Type ribbon:RibbonGallery}">
                <Style.Resources>
                    <!-- Note that this Style has been specified only to trump the 
                         implicit style for RibbonMenuItem from being picked by the 
                         items within the FilterMenuButton -->
                    <Style TargetType="{x:Type ribbon:RibbonMenuItem}" />
                </Style.Resources>
                <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{Binding SmallImage}" />
                <Setter Property="ItemsSource" Value="{Binding CategoryDataCollection}" />
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="SelectedItem" Value="{Binding SelectedItem}" />
                <Setter Property="CanUserFilter" Value="{Binding CanUserFilter}" />
                <Setter Property="FilterItemContainerStyle" Value="{StaticResource FilterMenuItemStyle}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SmallImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.SmallImageSource" Value="{x:Null}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonGalleryCategory -->
            <Style TargetType="{x:Type ribbon:RibbonGalleryCategory}">
                <Setter Property="Header" Value="{Binding Label}" />
                <Setter Property="ItemsSource" Value="{Binding GalleryItemDataCollection}" />
            </Style>

            <!-- RibbonMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonMenuItem}">
                <Setter Property="Header" Value="{Binding Label}" />
                <Setter Property="ImageSource" Value="{Binding SmallImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipTitle" Value="{Binding ToolTipTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipDescription" Value="{Binding ToolTipDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{Binding ToolTipImage}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterTitle" Value="{Binding ToolTipFooterTitle}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterDescription" Value="{Binding ToolTipFooterDescription}" />
                <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{Binding ToolTipFooterImage}" />
                <Setter Property="KeyTipService.KeyTip" Value="{Binding KeyTip}" />
                <Setter Property="Command" Value="{Binding Command}" />
                <Setter Property="IsCheckable" Value="{Binding IsCheckable}" />
                <Setter Property="IsChecked" Value="{Binding IsChecked}" />
                <Setter Property="CanUserResizeVertically" Value="{Binding IsVerticallyResizable}" />
                <Setter Property="CanUserResizeHorizontally" Value="{Binding IsHorizontallyResizable}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SmallImage}" Value="{x:Null}">
                        <Setter Property="ImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ToolTipFooterImage}" Value="{x:Null}">
                        <Setter Property="ribbon:RibbonControlService.ToolTipFooterImageSource" Value="{x:Null}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonSplitMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonSplitMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuItem}}">
                <Setter Property="HeaderQuickAccessToolBarId" Value="{Binding Command}" />
                <Setter Property="QuickAccessToolBarId" Value="{Binding DropDownButtonData.Command}" />
                <Setter Property="HeaderKeyTip" Value="{Binding KeyTip}" />
                <Setter Property="KeyTip" Value="{Binding DropDownButtonData.KeyTip}" />
                <Setter Property="DropDownToolTipTitle" Value="{Binding DropDownButtonData.ToolTipTitle}" />
                <Setter Property="DropDownToolTipDescription" Value="{Binding DropDownButtonData.ToolTipDescription}" />
                <Setter Property="DropDownToolTipImageSource" Value="{Binding DropDownButtonData.ToolTipImage}" />
                <Setter Property="DropDownToolTipFooterTitle" Value="{Binding DropDownButtonData.ToolTipFooterTitle}" />
                <Setter Property="DropDownToolTipFooterDescription" Value="{Binding DropDownButtonData.ToolTipFooterDescription}" />
                <Setter Property="DropDownToolTipFooterImageSource" Value="{Binding DropDownButtonData.ToolTipFooterImage}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding DropDownButtonData.ToolTipImage}" Value="{x:Null}">
                        <Setter Property="DropDownToolTipImageSource" Value="{x:Null}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding DropDownButtonData.ToolTipFooterImage}" Value="{x:Null}">
                        <Setter Property="DropDownToolTipFooterImageSource" Value="{x:Null}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonApplicationMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonApplicationMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonMenuItem}}">
                <Style.Triggers>
                    <Trigger Property="Level" Value="Middle">
                        <Setter Property="ImageSource" Value="{Binding SmallImage}" />
                        <Setter Property="KeyTipService.KeyTip" Value="{Binding KeyTip}" />
                        <Setter Property="Command" Value="{Binding Command}" />
                        <Setter Property="Header" Value="{Binding}" />
                        <Setter Property="HeaderTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <AccessText Grid.Row="0" FontWeight="Bold" Text="{Binding Label}" />
                                        <TextBlock Grid.Row="1" Text="{Binding ToolTipTitle}" TextWrapping="Wrap" />
                                    </Grid>
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <!-- RibbonApplicationSplitMenuItem -->
            <Style TargetType="{x:Type ribbon:RibbonApplicationSplitMenuItem}" BasedOn="{StaticResource {x:Type ribbon:RibbonSplitMenuItem}}" />

            <!-- RibbonContextMenu -->
            <Style TargetType="{x:Type ribbon:RibbonContextMenu}">
                <Style.Resources>
                    <!-- Note that this Style has been specified only to trump the 
                         implicit style for RibbonMenuItem from being picked by the 
                         items within the ContextMenu -->
                    <Style TargetType="{x:Type ribbon:RibbonMenuItem}" />
                </Style.Resources>
            </Style>

            <!-- RibbonControlGroup -->
            <Style TargetType="{x:Type ribbon:RibbonControlGroup}">
                <Setter Property="Margin" Value="2,0,2,0" />
            </Style>

            <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <!-- RibbonContextualTabGroup -->
            <Style TargetType="{x:Type ribbon:RibbonContextualTabGroup}">
                <Setter Property="Header" Value="{Binding Header}" />
                <Setter Property="Visibility" Value="{Binding IsVisible,Converter={StaticResource BoolToVisibilityConverter}}" />
            </Style>

            <!-- RibbonTab -->
            <Style TargetType="{x:Type ribbon:RibbonTab}" x:Key="ContextualTabStyle">
                <Setter Property="ContextualTabGroupHeader" Value="{Binding ContextualTabGroupHeader}" />
                <Setter Property="Header" Value="{Binding Header}" />
                <Setter Property="IsSelected" Value="{Binding IsSelected}" />
            </Style>
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <ribbon:Ribbon x:Name="ribbon">
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu SmallImageSource="Resources\Document_16x16.png" KeyTip="F">
                    <ribbon:RibbonApplicationMenuItem DataContext="{x:Static data:rzd_model.New}" />
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>
            <ribbon:RibbonTab Header="Главная" >
                <ribbon:RibbonGroup x:Name="MapProvider" DataContext="{x:Static data:rzd_model.MapProvider}">
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Bing}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.OpenStreetMap}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Plain}" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="KindInfo">
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Vehicle}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Stations}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Road}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Markers}" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="KindMap">
                    <ribbon:RibbonSplitButton DataContext="{x:Static data:rzd_model.LookMap}">
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:rzd_model.LookMap}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:rzd_model.LookRoad}" />
                        <ribbon:RibbonMenuItem DataContext="{x:Static data:rzd_model.LookHybrid}" />
                    </ribbon:RibbonSplitButton>

                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Scale100}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Scale10}" />
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Reportsr" DataContext="{x:Static data:rzd_model.Graphics}">
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Graphic1}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Graphic2}" />
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Graphic3}" />
                </ribbon:RibbonGroup>

                <ribbon:RibbonGroup x:Name="Options" DataContext="{x:Static data:rzd_model.Options}">
                    <ribbon:RibbonButton DataContext="{x:Static data:rzd_model.Options}" />
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
        </ribbon:Ribbon>
    </Grid>
</UserControl>
